﻿/**
追雨潮工作流引擎处理  @追雨潮
**/
//var spPageUrl = "../ashx/spui.ashx";//后台统一页面
//var spPageHtmlName = "本html名称";//如index
//var pTableName = "";//增删改的，表名
//var pTableIdName = "";//增删改的，表主键
//var grid1ID = "";//列表的ID
//var selTableinfo = "";//查询table信息 主表一定要as T 
//var selFieldsinfo = "*";//查询返回的内容
//var pPageCode = "";
//var pPageInfoName = "-";

//var auhcotype = "";
//var aumid = "";  


//发起流程
function hcrf_start() {
    if (aumid == null || aumid == "") {
        layer.alert("业务没保存，不能发起", { icon: 2 });
        return;
    }
    if (pPageCode == null || pPageCode == "") {
        layer.alert("业务代码为空，不能发起", { icon: 2 });
        return;
    }

    $.ajax({
        type: "post",
        url: spPageUrl,
        data: {
            "action": "hcrf_start",
            "fruntype": pPageCode,
            "frunywid": aumid,
            "fhcrdostate": "发起",
            "fdesc": "发起业务"
        },
        timeout: 9000,
        async: true,
        cache: false,
        error: function (error) {
            layer.msg(error, { shift: 6 });
        },
        success: function (data) {
            var result = JSON.parse(data);
            switch (result.message) {
                case JsonResult.Success:
                    layer.msg('发起成功', { shift: 6 });
                    break;
                case JsonResult.Error:
                    if (result.data.indexOf("index_w_runti") > 0) {
                        layer.msg("不需要重复发起!", { shift: 6 });
                    }
                    else
                        layer.msg(result.data, { shift: 6 });
                    break;
                default:
                    break;
            }

        }
    });


}
//初始化工作流功能栏
function hcrfbutton() {
    //流程步骤名称


    var setupname = "发起";
    var divshow = $("#divforhcrfbutton");
    divshow.text("");// 清空数据
    if (aumid == null || aumid == "")
    {
        //没有处理——————查找发起的权限
        divshow.append("工作流操作-当前步骤:<strong style=\"font-weight: bold; color: #FF0000; padding-top: 1px;\">" + setupname + "</strong><br/>");
        divshow.append("<a onclick=\"hcrf_start()\" class=\"btn btn-primary radius\">发起</a>&nbsp;");
    }
    else
    {
        //没有处理——————查找发起的权限
        //
        divshow.append("工作流操作-当前步骤:<strong style=\"font-weight: bold; color: #FF0000; padding-top: 1px;\">" + setupname + "</strong><br/>");
        divshow.append("<a onclick=\"hcrf_che_ok()\" class=\"btn btn-primary radius\">通过</a>&nbsp;");
        divshow.append("<a onclick=\"hcrf_che_no()\" class=\"btn btn-primary radius\">退回</a>&nbsp;");
    }
}
//工作流列表查询
function spselUrl_hf(spadd) {
    if (spadd != null && spadd != "undefined" && spadd.length > 0)
    { return spPageUrl + "?action=selhf&wycode=" + pPageCode + "&tableinfo=" + escape(selTableinfo) + "&refields=" + escape(selFieldsinfo) + "&wheresp= " + spadd; }
    else
        return spPageUrl + "?action=sehfl&wycode=" + pPageCode + "&tableinfo=" + escape(selTableinfo) + "&refields=" + escape(selFieldsinfo) + "";
}